//
//  TZQRCodeController.m
//  BSBDJ
//
//  Created by user on 16/5/24.
//  Copyright © 2016年 Burning. All rights reserved.
//

#import "TZQRCodeController.h"
#import "QRCodeTool.h"
@interface TZQRCodeController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBottom;
@property (weak, nonatomic) IBOutlet UIView *chongjiboView;
@property (weak, nonatomic) IBOutlet UIImageView *saomiaoImage;
@property (nonatomic, strong) QRCodeTool *codeTool;

@end

@implementation TZQRCodeController

- (QRCodeTool *)codeTool
{
    if (_codeTool == nil) {
        _codeTool = [QRCodeTool shareInstance];
        
    }
    return _codeTool;
}

- (void)viewDidLoad {
    [super viewDidLoad];

//    [SVProgressHUD showWithStatus:@"正在打开照相机"];
    [self starScanf];
  
}

- (void)starScanf{
    [self.codeTool setInterestRect:self.chongjiboView.bounds];
    [self.codeTool scanfQRCodeInView:self.view isDraw:YES :^(NSArray<NSString *> *resultStrs) {
        NSLog(@"%@",resultStrs);
    }];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [self starAnimation];

}

- (void)starAnimation{
    
    // 先移动动画到顶部
    self.constraintBottom.constant = self.chongjiboView.height;
    
    [self.view layoutIfNeeded];
    
    
    // 再移动动画到底部
    self.constraintBottom.constant = - self.chongjiboView.height;
    
    [UIView animateWithDuration:2 animations:^{
        // 不断执行动画
        [UIView setAnimationRepeatCount:MAXFLOAT];
        [self.view layoutIfNeeded ];
    }];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
